package whf.framework.security.entity;

import java.sql.Blob;
import java.sql.Date;
import java.sql.Timestamp;

import whf.framework.entity.AbstractEntity;

/**
 * @author wanghaifeng
 * 
 */
public class User extends AbstractEntity {
	private String username; //登陆用户名

	private String password;
	
	/**
	 * @property Date:passwordModifyDate 最近的密码修改时间
	 */
	private Date passwordModifyDate;

	/**
	 * @property Date:lastLogin 最精登陆事件
	 */
	private Timestamp lastLogin;

	/**
	 * 账户是否国企
	 * @property boolean:accountNonExpired
	 */
	private boolean accountNonExpired;

	/**
	 * 帐号是否被锁
	 * @property boolean:accountNonLocked
	 */
	private boolean accountNonLocked = true;

	/**
	 * 凭证是否过期
	 * @property boolean:credentialsNonExpired
	 */
	private boolean credentialsNonExpired = true;

	/**
	 * @property boolean:enabled 是否有效
	 */
	private boolean enabled = true;
	
	//info
	private String firstName;

	private String lastName;

	private String email;

	private String mobile;

	private String tel1;

	private String tel2;
	
	private String address1;
	
	private String address2;
	
	private String zip;
	
	/**
	 * @property String:lastLoginIP 最近登陆的IP地址
	 */
	private String lastLoginIP;
	
	/**
	 * @property UserType:userType
	 */
	private UserType userType;
	
	/**
	 * @property Blob:photo 相片
	 */
	private Blob photo;

	private String branch;
	
	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getLastLogin()
	 */
	public Timestamp getLastLogin() {
		return lastLogin;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setLastLogin(java.sql.Timestamp)
	 */
	public void setLastLogin(Timestamp lastLogin) {
		this.lastLogin = lastLogin;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getLastLoginIP()
	 */
	public final String getLastLoginIP() {
		return lastLoginIP;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setLastLoginIP(java.lang.String)
	 */
	public final void setLastLoginIP(String lastLoginIP) {
		this.lastLoginIP = lastLoginIP;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getUsername()
	 */
	public String getUsername() {
		return username;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setUsername(java.lang.String)
	 */
	public void setUsername(String login) {
		this.username = login;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getPassword()
	 */
	public String getPassword() {
		return password;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setPassword(java.lang.String)
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#isAccountNonExpired()
	 */
	public boolean isAccountNonExpired() {
		return accountNonExpired;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setAccountNonExpired(boolean)
	 */
	public void setAccountNonExpired(boolean accountNonExpired) {
		this.accountNonExpired = accountNonExpired;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#isAccountNonLocked()
	 */
	public boolean isAccountNonLocked() {
		return accountNonLocked;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setAccountNonLocked(boolean)
	 */
	public void setAccountNonLocked(boolean accountNonLocked) {
		this.accountNonLocked = accountNonLocked;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#isCredentialsNonExpired()
	 */
	public boolean isCredentialsNonExpired() {
		return credentialsNonExpired;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setCredentialsNonExpired(boolean)
	 */
	public void setCredentialsNonExpired(boolean credentialsNonExpired) {
		this.credentialsNonExpired = credentialsNonExpired;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#isEnabled()
	 */
	public boolean isEnabled() {
		return enabled;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setEnabled(boolean)
	 */
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	//info

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getEmail()
	 */
	public String getEmail() {
		return email;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setEmail(java.lang.String)
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getFirstName()
	 */
	public String getFirstName() {
		return firstName;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setFirstName(java.lang.String)
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getLastName()
	 */
	public String getLastName() {
		return lastName;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setLastName(java.lang.String)
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getMobile()
	 */
	public String getMobile() {
		return mobile;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setMobile(java.lang.String)
	 */
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getTel1()
	 */
	public String getTel1() {
		return tel1;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setTel1(java.lang.String)
	 */
	public void setTel1(String tel1) {
		this.tel1 = tel1;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getTel2()
	 */
	public String getTel2() {
		return tel2;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setTel2(java.lang.String)
	 */
	public void setTel2(String tel2) {
		this.tel2 = tel2;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getAddress1()
	 */
	public final String getAddress1() {
		return address1;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setAddress1(java.lang.String)
	 */
	public final void setAddress1(String address1) {
		this.address1 = address1;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getAddress2()
	 */
	public final String getAddress2() {
		return address2;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setAddress2(java.lang.String)
	 */
	public final void setAddress2(String address2) {
		this.address2 = address2;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getPhoto()
	 */
	public final Blob getPhoto() {
		return photo;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setPhoto(java.sql.Blob)
	 */
	public final void setPhoto(Blob photo) {
		this.photo = photo;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getZip()
	 */
	public final String getZip() {
		return zip;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setZip(java.lang.String)
	 */
	public final void setZip(String zip) {
		this.zip = zip;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getPasswordModifyDate()
	 */
	public final Date getPasswordModifyDate() {
		return passwordModifyDate;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setPasswordModifyDate(java.sql.Date)
	 */
	public final void setPasswordModifyDate(Date passwordModifyDate) {
		this.passwordModifyDate = passwordModifyDate;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#getUserType()
	 */
	public final UserType getUserType() {
		return userType;
	}

	/* (non-Javadoc)
	 * @see whf.framework.auth.entity.IUser#setUserType(whf.framework.auth.entity.UserType)
	 */
	public final void setUserType(UserType userType) {
		this.userType = userType;
	}
	
	public String getDisplayName() {
		if(this.getDept() != null) {
			return this.getDept().getDisplayName() + " &gt;&gt; " + this.getName();
		} else {
			return this.getName();
		}
	}

	public String getBranch() {
		return branch;
	}

	public void setBranch(String branch) {
		this.branch = branch;
	}
}
